/**
 * 				MusicItem.java
 *				------------
 *		
 *   Author:	bin04017@gmail.com
 *	 Created:	13.12.2006
 *	 Project:	MP3-Sync (Mochito)
 *	 Package:	dataClasses
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 */
package mochito.dataClasses.musicItem;

import java.io.File;
import java.io.FileInputStream;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;

/**
 * @author bin04017
 */
public class MusicItem extends UnicastRemoteObject {
	/**
	 * 
	 */
	private static final long serialVersionUID = -6368086684714537698L;

	private String name;

	private String startTime = null;
	
	private String startDate = null;

	private File file;

	private byte[] bArray;

	public MusicItem(String name) throws RemoteException {
		this.name = name;
	}

	public MusicItem(String name, File file) throws RemoteException {
		this.name = name;
		this.setFile(file);
	}

	public MusicItem(String name, String fileName) throws RemoteException {
		this.name = name;
		this.setFile(fileName);
	}

	/**
	 * 
	 * @param fname
	 * @return byte[]
	 */
	public byte[] retrieveFile() {
		try {

			FileInputStream is = new FileInputStream(file);
			byte[] b = new byte[(int) file.length()];
			is.read(b);
			bArray = b;
			return bArray;
		} catch (Exception e) {
		}
		return bArray;
	}

	/**
	 * @return the startTime
	 */
	public String getStartTime() {
		return startTime;
	}

	/**
	 * @param startTime
	 *            the startTime to set
	 */
	public void setStartTime(int hour, int min, int sec) {
		this.startTime = hour+":"+min+":"+sec;
	}
	/**
	 * @param startTime
	 *            the startTime to set
	 */
	public void setStartTime(String time) {
		this.startTime = time;
	}
	
	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @return the fileName
	 */
	public File getFile() {
		return file;
	}

	/**
	 * @param fileName
	 *            the fileName to set
	 */
	public void setFile(String fileName) {
		this.file = new File(fileName);
	}

	/**
	 * @param file
	 *            the file to set
	 */
	public void setFile(File file) {
		this.file = file;
	}

	public String getStartDate() {
		return startDate;
	}

	public void setStartDate(int year, int month, int day) {
		this.startDate = year+"/"+month+"/"+day;
	}
	public void setStartDate(String date) {
		this.startDate = date;
	}
}
